local ngx = ngx
local call_utils = require("utils.call_utils")
local setmetatable = setmetatable

local _M = {}

local mt = {__index = _M}

function _M.do_in_rewrite(self)
    local ngx_ctx = ngx.ctx
    ngx_ctx.api_ctx = ngx_ctx.api_ctx or {}
    call_utils.call(self.plugins, "do_in_rewrite")
end

function _M.do_in_access(self)
    call_utils.call(self.plugins, "do_in_access")
end

function _M.do_in_content(self)
    call_utils.call(self.plugins, "do_in_content")
end

function _M.do_in_balancer(self)
    call_utils.call(self.plugins, "do_in_balancer")
end

function _M.do_in_header_filter(self)
    call_utils.call(self.plugins, "do_in_body_filter")
end

function _M.do_in_body_filter(self)
    call_utils.call(self.plugins, "do_in_body_filter")
end

function _M.do_in_log(self)
    call_utils.call(self.plugins, "do_in_log")
end

function _M.new(self, plugins)
    self.plugins = plugins
    return setmetatable(self, mt)
end

return _M
